package com.etc.service.impl;

import java.util.List;

import com.etc.entity.AsBoard;
import com.etc.mapper.AsBoardMapper;
import com.etc.service.IAsBoardService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 画报管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-11-27
 */
@Service
public class AsBoardServiceImpl implements IAsBoardService
{
    @Autowired
    private AsBoardMapper asBoardMapper;

    /**
     * 查询画报管理
     *
     * @param id 画报管理主键
     * @return 画报管理
     */
    @Override
    public List<AsBoard> selectAsBoardByUserId(Long id)
    {
        return asBoardMapper.selectAsBoardByUserId(id);
    }

    @Override
    public AsBoard selectAsBoardByBoardId(Long id) {
        return asBoardMapper.selectAsBoardByBoardId(id);
    }

    /**
     * 查询画报管理列表
     * 
     * @param
     * @return 画报管理
     */
    @Override
    public Page<AsBoard> selectAsBoardList(String keywords, int  page, int limit)
    {
        PageHelper.startPage(page,limit);
        List<AsBoard> asBoards = asBoardMapper.selectAsBoardList("%" + keywords + "%");
        return (Page<AsBoard>) asBoards;
    }

    /**
     * 新增画报管理
     * 
     * @param asBoard 画报管理
     * @return 结果
     */
    @Override
    public AsBoard insertAsBoard(AsBoard asBoard)
    {
        int i = asBoardMapper.insertAsBoard(asBoard);
        List<AsBoard> asBoards = asBoardMapper.selectAsBoardList(asBoard.getTitle());

        return asBoards.get(0);
    }

    /**
     * 修改画报管理
     * 
     * @param asBoard 画报管理
     * @return 结果
     */
    @Override
    public int updateAsBoard(AsBoard asBoard)
    {
        return asBoardMapper.updateAsBoard(asBoard);
    }

    /**
     * 批量删除画报管理
     * 
     * @param ids 需要删除的画报管理主键
     * @return 结果
     */
    @Override
    public int deleteAsBoardByIds(Long[] ids)
    {
        return asBoardMapper.deleteAsBoardByIds(ids);
    }

    /**
     * 删除画报管理信息
     * 
     * @param id 画报管理主键
     * @return 结果
     */
    @Override
    public int deleteAsBoardById(Long id)
    {
        return asBoardMapper.deleteAsBoardById(id);
    }
}
